//当前模块的作用：所有的api接口进行统一管理
import requests from "./request";
import mockRequests from "./mockAjax"
//三级联动的接口
///api/product/getBaseCategoryList get 无参数

export const reqCategoryList = () => {
    //发请求:axios发请求，结果是Promise对象
    return requests({ url: '/product/getBaseCategoryList', method: 'get' })
}
//获取panner(Home首页轮播图接口)
export const reqGetBannerList = () => {
    return mockRequests({ url: '/banner', method: 'get' })
}
//获取floor组件的数据
export const reqFloorList = () => {
    return mockRequests({ url: '/floor', method: 'get' })
}
//获取搜索模块数据 /api/list
/*
{
    "category3Id": "61",
    "categoryName": "手机",
    "keyword": "小米",
    "order": "1:desc",
    "pageNo": 1,
    "pageSize": 10,
    "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
    "trademark": "4:小米"
} 
*/
//当前这个接口，给服务器传递参数params,至少是一个空对象
export const reqGetSearchInfo = (params) => {
    return requests({ url: '/list', method: 'post', data: params })
}

//获取产品详情信息的接口URL:/api/item/(skuId}请求方式：get

export const reqGoodsInfo = (skuId) => {
    return requests({ url: `/item/${skuId}`, method: 'get', })
}

//将产品添加到购物车中（获取更新某一个产品的个数）
///api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
    return requests({
        url: `/cart/addToCart/${skuId}/${skuNum}`,
        method: 'post'
    })
}

//获取购物车链表的数据接口
//URL /cart/cartList
export const reqCartList = () => {
    return requests({ url: '/cart/cartList', method: 'get' })
}

//删除购物产品的接口
//  /cart/deleteCart/{skuId}
export const reqDeleteCartById = (skuId) => {
    return requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })
}

//修改商品选中的状态
// /cart/checkCart/{skuID}/{isChecked} get
export const reqUpdateCheckedById = (skuId, isChecked) => {
    return requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })
}

//获取验证码
// /api/user/passport/sendCode/{phone}
export const reqGetCode = (phone) => {
    return requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
}

//注册验证码
// /user/passport/register
export const reqUserRegister = (data) => {
    return requests({ url: '/user/passport/register', method: 'post', data })
}

//登录
// /user/passport/login
export const reqUserLogin = (data) => {
    return requests({ url: '/user/passport/login', method: 'post', data })
}

//通过token获取用户学习
export const reqUserInfo = () => {
    return requests({ url: '/user/passport/auth/getUserInfo', method: 'get' })
}

//退出登录
export const reqLogout = () => {
    return requests({ url: '/user/passport/logout', method: 'get' })
}

//获取用户地址信息
// /user/userAddress / auth / findUserAddressList
export const reqAddressInfo = () => {
    return requests({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })
}

//获取购物车商品清单
// /order/auth/trade
export const reqOrderInfo = () => {
    return requests({ url: '/order/auth/trade', method: 'get' })
}

//提交订单
// /order/auth/submitOrder?tradeNo={tradeNo} post
export const reqSubmitOrder = (tradeNo, data) => {
    return requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', data })
}

//支付订单
// payment/weixin/createNative/{orderId}
export const reqPayInfo = (orderId) => {
    return requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })
}

//支付结果
// /payment/weixin/queryPayStatus/{orderId}
export const reqPayStatus = (orderId) => {
    return requests({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })
}

//获取个人中心订单
// /order/auth/{page}/{limit}

export const reqMyOrderList = (page, limit) => {
    return requests({ url: `/order/auth/${page}/${limit}`, method: 'get' })
}